<div class="right_side_operate_area">

    <?php  
        $user=$session->read('User');
        $isflag=true;
        //if($user['isadmin'] || $user['isgroupadmin']){
        //	$isflag=true;
        //}
        if($showpage==1) {
            if(isset($paging)){ echo $this->renderElement('pagination',$paging);} 
        }
    ?>
    <div class="right item_add_btn">
    	<?php if(classregistry::init('User')->personAuthority($user)){
    		?>
    	<a href="../companys/editinfo">添加</a>
    	<?php }?>
    </div>
    <!-- 更新科创园，大科园企业信息 
    <?php if(classregistry::init('User')->adminAuthority($user)){
    $path=Router::url(array('controller' => '/', 'action' =>''), true);
    	?>
    <div class="right item_add_btn">
    	<a href="<?php echo $path ?>companys/updatecompany">更新</a>
    </div>
    <?php }?>
    -->
    <div class="right search_box">
        <form onsubmit="return searchcompany()">
            <div class="left search_text" style="width:140px;" >
                <?php echo $form->text('company.keyword',array('placeholder'=>'搜索企业名称','value'=>$keyword, 'id'=>'search', 'class'=>'text_box',"style"=>"width:140px;"));?>
            </div>
            <div class="left search_btn" style="left:-90px;"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
    <div class="term_choose_area right">
        <a class="term_choose_btn" id="term_choose_btn" title="选择"></a>
        <div class="screen_list" id="screen_list" style="display:none;visibility:hidden;">
            <ul>
                <?php 
                foreach($industrys as $key=>$strindustry){
                    $selected="";
                    if($industry==$key){
                        $selected="selected";
                    }
                    echo '<li class="'.$selected.'">';
                    echo $html->link($strindustry,"javascript:void(0)",array("onclick"=>"return setindustry('".$key."')","class"=>$selected));
                    echo '</li>';
                }
                ?>
            </ul>
            <div id="industry" style="display:none"><?php echo $industry?></div>
        </div>
    </div>
    <div style="height:50px;font-size:14px;" class="right">
		<style>
		.align_middle{margin-top:15px; margin-left:15px;text-align:center;}
		</style>	
		<div class="right_side_title right align_middle">
			 <?php 
			 $user=$session->read('User');
			 if($user['isadmin']||$user['isvisitor']){
				$grouplist=array_merge(array(""=>"请选择模块"),$grouplist);
		    	echo $form->select('ddlgroup',$grouplist, $group_mod_id, null,null);
			 }
		     ?>
		</div>  



        <div style="height:20px;text-align:center;float:left;margin-right:20px;margin-top:15px;cursor: pointer;">
	        <select name="un_post_date" id="un_post_date" >
		        <option value=''>未提交经济数据</option>
		        <?php foreach($no_post as $no_post_k=>$no_post_v):?>
		        <?php foreach($no_post_v as $no_post_v1):?>
		        <option <?php echo $unpost==$no_post_k.'-'.$no_post_v1 ? 'selected':'';?> value="<?php echo $no_post_k.'-'.$no_post_v1; ?>"><?php echo $no_post_k.'年'.$no_post_v1.'月';?></option>
		        <?php endforeach;?>
		        <?php endforeach;?>
	        </select>
       	</div>
   
        <div style="height:20px;text-align:center;float:left;margin-top:15px;cursor: pointer;">
	        <select name="un_check" id="un_check" >
		        <option value=''>待审核</option>
		        <?php foreach($no_check as $no_check_k=>$no_check_v):?>
		        <?php foreach($no_check_v as $no_check_v1):?>
		        <option <?php echo $uncheck==$no_check_k.'-'.$no_check_v1 ? 'selected':'';?> value="<?php echo $no_check_k.'-'.$no_check_v1; ?>"><?php echo $no_check_k.'年'.$no_check_v1.'月';?></option>
		        <?php endforeach;?>
		        <?php endforeach;?>
        	</select>
       </div>
       
    </div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
            <?php 
                $upimg=$html->image("up.png");
                $downimg=$html->image("down.png");
                $capitalimg=$capitalsort=="desc"?$upimg:$downimg;
                $regimg=$regsort=="desc"?$upimg:$downimg;
            ?>
            <table>
                <tr>
                    <th>企业名称</th>
                    <th>模块</th>
                    <th>负责人</th>
                    <th>联系电话</th>
                    <th><?php echo $html->link('注册资金（万）'.$capitalimg,'javascript:void(0)',array('onclick'=>"return setsort('/capital/$capitalsort')",'escape' => false))?></th>
                    <th><?php echo $html->link('注册时间'.$regimg,'javascript:void(0)',array('onclick'=>"return setsort('/reg_time/$regsort')",'escape' => false))?></th>
                    <th><?php __("Action")?></th>
                </tr>
                <?php 
                foreach($companys as $company){
                    $id=$company["Company"]["id"];
                    $company_name=$company["Company"]["company_name"];
                    echo "<tr class='per_list'>";
                    echo "<td>".$html->link($str->sub_len($company_name,20),"/companys/showinfosummary/".$id,array("title"=>$company_name),null)."</td>";
					echo "<td>".$grouplist[$company["Company"]["groupid"]]."</td>";
                    echo "<td>".$company["Company"]["contact"]."</td>";
                    echo "<td>".$company["Company"]["tel"]."</td>";
                    $cap_type=$company["Company"]["cap_type"]=="0"?"￥":"＄";
                    echo "<td>".$cap_type.$company["Company"]["capital"]."</td>";
                    $reg_time=$company["Company"]["reg_time"];
                    if(!empty($reg_time)){
                        $reg_time=date("Y-m-d",strtotime($reg_time));
                    }
                    echo "<td>".$reg_time."</td>";
                    echo "<td>";
                    $email = base64_encode($company["Company"]["email"]);
                    if($isflag&&classregistry::init('User')->personAuthority($user)&&classregistry::init('Company')->compAthority($company["Company"])){
                        echo $html->link(__("Edit",true),"/companys/editinfo/".$id,null,null);
                        echo $html->link(__("Delete",true),"/companys/dels/".$id."/".$email,array("onclick"=>"return doaction(this)"));
                    }else{
                        echo "<span class='enableaction'>编辑</span>";
                        echo "<span class='enableaction'>删除</span>";
                    }
                    echo "</td>";
                    echo "</tr>";
                }
                ?>
            </table>
        </div>
    </div>
</div>

<?php echo $this->element('actionconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<?php echo $this->element('autocomplete',array("model_name"=>"Company","field_name"=>"company_name","widget_name"=>"search_company")) ?>
<div id="sort" class="txthide"><?php echo '/'.$sortBy.'/'.$direction?></div>
<script>
$(document).ready(function() {
	$("#ddlgroup").change(function(){
		searchtech();
		});
	$("#un_check").change(function(){
		searchtech();
	});
	$("#un_post_date").change(function(){
		searchtech();
	});
	$("#industry").change(function(){
		searchtech();
	});
	

});
function searchtech()
{
	var sort=$("#sort").html();
	var webpath=$("#getpath").attr('href');
	var urlpath=webpath+"companys/index"+sort+"?seach=all";

	var group=$("#ddlgroup").val();
    var inid=$("#industry").html();
    var un_check=$("#un_check").val();
    var un_post_date=$("#un_post_date").val();

    
    if(group=="" && inid=="" && un_check=="" && un_post_date==""){
    	 location.href=urlpath;
        }else{ 
            if(group!=""){
            	urlpath+="&group="+group;
                }
			if(inid.trim()!=""){
				urlpath+="&industry="+encodeURIComponent(inid.trim());
				}
			if(un_check!=""){
				urlpath+="&uncheck="+encodeURIComponent(un_check);
				}
	        if(un_post_date.trim()!=""){
	            urlpath+="&unpost="+encodeURIComponent(un_post_date.trim());
	        }
	      location.href=urlpath;   
        }
	 return false;
}




if($("#search").val()!=""){
    $("#search").focus();
}
function setindustry(inid){
    $("#industry").html(inid);
    return searchcompany();
}
function setsort(sort){
    $("#sort").html(sort);
    return searchcompany();
}
function searchcompany()
{	
    var sort=$("#sort").html();
    var webpath=$("#getpath").attr('href');
    var urlpath=webpath+"companys/index"+sort+"?seach=all";
    var inid=$("#industry").html();
    var search=$("#search").val();
	var group=$("#ddlgroup").val();
    var un_check=$("#un_check").val();
    var un_post_date=$("#un_post_date").val();
    if(inid=="" && search=="" && group=="" && un_check=="" && un_post_date==""){
        location.href=urlpath;
    }else{
        if(inid.trim()!=""){
            urlpath+="&industry="+inid.trim();
        }
        if(search.trim()!=""){
            urlpath+="&keyword="+encodeURIComponent(search.trim());
        }
        if(group!=""){
        	urlpath+="&group="+group;
            }
		if(un_check!=""){
			urlpath+="&uncheck="+encodeURIComponent(un_check);
			}
        if(un_post_date.trim()!=""){
            urlpath+="&unpost="+encodeURIComponent(un_post_date.trim());
        }
        
        location.href=urlpath;
    }
    return false;
}


function un_check(){
    var sort=$("#sort").html();
    var webpath=$("#getpath").attr('href');
    var urlpath=webpath+"companys/index"+sort+"?seach=all";
    var inid=$("#industry").html();
    var search=$("#un_check").val();
    if(inid=="" && search==""){
        location.href=urlpath;
    }else{
        
        if(search.trim()!=""){
            urlpath+="&uncheck="+encodeURIComponent(search.trim());
        }
        location.href=urlpath;
    }
    return false;

}
function un_post_date()
{	
    var sort=$("#sort").html();
    var webpath=$("#getpath").attr('href');
    var urlpath=webpath+"companys/index"+sort+"?seach=all";
    var inid=$("#industry").html();
    var search=$("#un_post_date").val();
    if(inid=="" && search==""){
        location.href=urlpath;
    }else{
        
        if(search.trim()!=""){
            urlpath+="&unpost="+encodeURIComponent(search.trim());
        }
        location.href=urlpath;
    }
    return false;
}


function focuseEV(C,B,A){
    if(window.attachEvent){
        C.attachEvent("on"+B,A);
    }else{
        if(window.addEventListener){
            C.addEventListener(B,A,false);
        }
    }
}
focuseEV(document,"click",function(E){
    var E=E||window.event;
    var A=E.target||E.srcElement;
    var D=window.event?E.button:E.which;
    var C=G("term_choose_btn"),B=G("screen_list");
    while(A&&A!=document.body&&A.tagName.toLowerCase()!="html"){
        if(A==C){break}
        if(A==B){break}
        A=A.parentNode
    }
    if(A==B){
    }else if(A!=C){
        B.style.display="none"
            B.style.visibility="hidden"
    }else{
        if(D<2){
            B.style.display=B.style.display=="block"?"none":"block";
            B.style.visibility=B.style.visibility=="hidden"?"visible":"hidden";
        }
    }
});
funPlaceholder(document.getElementById("search"));
</script>